package Data_Structure.List.SystemList;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.ListIterator;

/**
 * @className: Test
 * @author: 芃
 * @description: 测试系统List集合框架
 * @date: 2023/8/24 10:44
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);

    }
    //List的新增、查询
    public static void main1(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        //for循环打印
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
        //增强for循环打印 foreach
        for (int x: list) {
            System.out.print(x + " ");
        }
        System.out.println();
        //迭代器打印
        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next() + " ");
        }
        System.out.println();
        //List专用迭代器打印
        ListIterator<Integer> listIterator = list.listIterator();
        while (listIterator.hasNext()){
            System.out.print(listIterator.next() + " ");
        }
    }
}
